use macro_colors::*;
use std::path::Path;
use wax::{CandidatePath, Glob, Pattern};

pub fn wax_te1() {
    // Match a path against a glob:
    let glob = Glob::new("*.png").unwrap();
    assert!(glob.is_match("logo.png"));

    // Match a path against a glob with matched text (captures):
    let glob = Glob::new("**/{*.{go,rs}}").unwrap();
    let path = CandidatePath::from("src/main.go");
    let matched = glob.matched(&path).unwrap();
    blue_println!("matched text: {:?}", matched.get(0).unwrap());

    assert_eq!("main.go", matched.get(2).unwrap());
}

pub fn wax_te2() {
    // Match a directory tree against a glob:
    let directory = Path::new(".").canonicalize().unwrap(); // Working directory.
    blue_println!("current dir: {:?}", directory);

    let glob = Glob::new("**/*[ab]*.{md,rs,toml}").unwrap();
    for (i, entry) in glob.walk(directory).enumerate() {
        if let Ok(entry) = entry {
            blue_println!("entry {}: {:?}", i, entry.path());
        }
    }
}
